package com.breaktian.share.action;

import android.content.Context;

import com.breaktian.share.Config;
import com.breaktian.share.ShareChannel;
import com.breaktian.share.ShareEntity;
import com.tencent.tauth.Tencent;

public class QQAction implements ShareAction {
    private final Context mContext;
    private static Tencent mTencent;

    public QQAction(Context context) {
        this.mContext = context;
        try {
            if (mTencent == null) {
                mTencent = Tencent.createInstance(Config.QQ_APP_ID, context.getApplicationContext());
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    static Tencent getTencent() {
        return mTencent;
    }

    @Override
    public boolean isAppInstalled() {
        return mTencent != null && mTencent.isQQInstalled(mContext);
    }

    @Override
    public void share(ShareEntity entry, ShareChannel channel) {
        ShareActivity.start(mContext, entry, channel.getType());
    }
}
